package com.xmhu2009.applications.entity.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import com.xmhu2009.common.mybatis.EnumCodeGetter;
import com.xmhu2009.common.mybatis.EnumDescriptionGetter;

public enum DataEnum implements EnumCodeGetter, EnumDescriptionGetter {
    TYPE_IMAGE("image", "图片信息");

    private String code;

    private String description;

    DataEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    @JsonValue
    public String getCode() {
        return code;
    }

    public static DataEnum getEnumByCode(String code) {
        DataEnum[] values = DataEnum.values();
        for (DataEnum woTypeEnum : values) {
            if (woTypeEnum.getCode().equals(code)) {
                return woTypeEnum;
            }
        }
        return null;
    }
}
